GBML manual / Text

draw_text_3d_sheared

draw_text_3d with the whole line leaned the way italic writing leans: draws text in world space with the line curving away from you, and xshear slides the top of the letters sideways (a positive number leans them right, a negative number leans them left, and 0 is exactly draw_text_3d). shape and depth work exactly as they do in draw_text_3d: depth goes up to 6, and TEXT_DRUM and TEXT_BAND slide the word through a lens fixed on the middle of the screen. (x, y) is the same LEFT/CENTER/RIGHT anchor draw_text already uses. Inside a Draw GUI event it is fixed to the screen instead, and (x, y) counts from the screen’s top-left pixel.

Works differently on Game Boy - The Game Boy cannot squeeze letters row by row: with an xshear a 3D text on the screen leans in 4 steps of 2 lines and the shape is left out; without one it is as draw_text_3d (a copy behind, an arch, the lens).

Works differently on Game Boy Color - The Game Boy Color cannot squeeze letters row by row: with an xshear a 3D text on the screen leans in 4 steps of 2 lines and the shape is left out; without one it is as draw_text_3d (a copy behind, an arch, the lens).

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

draw_text_3d_sheared(x, y, text, shape, depth, xshear)

Arguments

NameType
xreal
yreal
textstring
shapetext_shape
depthint
xshearreal

Returns

Nothing.

Description

draw_text_3d with a slant. The line of text curves away from you as it always did, and xshear leans the whole line the way italic writing leans. It is the same number draw_text_sheared and draw_sprite_sheared take, and it means the same thing here:

A real capture - the word LEAN drawn three times with TEXT_BULGE at depth 4, one under the other. The top one has an xshear of 0, so it is exactly what draw_text_3d draws and every letter stands straight up. The middle one has an xshear of 0.5 and every letter leans to the right. The bottom one has an xshear of 1, and the letters lean much further, about as far as the letters are tall. Every letter is still pinched to a point at its top and bottomA real capture - the word LEAN drawn three times with TEXT_BULGE at depth 4, one under the other. The top one has an xshear of 0, so it is exactly what draw_text_3d draws and every letter stands straight up. The middle one has an xshear of 0.5 and every letter leans to the right. The bottom one has an xshear of 1, and the letters lean much further, about as far as the letters are tall. Every letter is still pinched to a point at its top and bottom
A real capture - the word LEAN drawn three times with TEXTBULGE at depth 4, one under the other. The top one has an xshear of 0, so it is exactly what drawtext_3d draws and every letter stands straight up. The middle one has an xshear of 0.5 and every letter leans to the right. The bottom one has an xshear of 1, and the letters lean much further, about as far as the letters are tall. Every letter is still pinched to a point at its top and bottom

The same call three times, with only the lean changing: 0, 0.5 and 1. Real pictures from a Game Boy Advance ROM, cropped and shown twice as big. The top one is draw_text_3d's own picture: the engine checks that, pixel for pixel, for every shape.

The first five numbers are draw_text_3d's own: (x, y), the text, the shape and the depth. The last one is the lean. Nothing about the first five changes:

A real capture - the word LEAN leaning to the right (an xshear of 0.5) in each of the five shapes, one under the other. TEXT_BULGE pinches every letter at the top and bottom, TEXT_LEAN_BACK makes the tops of the letters narrow, TEXT_LEAN_FORWARD makes the bottoms narrow, and TEXT_DRUM and TEXT_BAND make the word smaller as it gets further from the middle of the screenA real capture - the word LEAN leaning to the right (an xshear of 0.5) in each of the five shapes, one under the other. TEXT_BULGE pinches every letter at the top and bottom, TEXT_LEAN_BACK makes the tops of the letters narrow, TEXT_LEAN_FORWARD makes the bottoms narrow, and TEXT_DRUM and TEXT_BAND make the word smaller as it gets further from the middle of the screen
A real capture - the word LEAN leaning to the right (an xshear of 0.5) in each of the five shapes, one under the other. TEXTBULGE pinches every letter at the top and bottom, TEXTLEANBACK makes the tops of the letters narrow, TEXTLEANFORWARD makes the bottoms narrow, and TEXTDRUM and TEXT_BAND make the word smaller as it gets further from the middle of the screen

All five shapes, each leaning by 0.5. TEXT_DRUM and TEXT_BAND are a lens fixed on the middle of the screen, so their word is drawn there.

The lean and the curve work together. Where the curve squeezes a row of the letters, that row leans less, so the line leans like a real sign standing at an angle, not like a flat picture that has been pushed sideways. You do not have to do anything for that: it is the same number on every row, and the curve does the rest.

A lean that changes

The lean can be a different number on every frame, and it costs almost nothing to change: the letters are not built again. A swinging lean, a lean that follows how fast something moves, a word that falls over when it is hit: all of them are one variable.

A real capture, 16 frames played in a loop - the word LEAN with TEXT_BULGE at depth 4, its lean swinging from far to the right (xshear 1) through standing straight up (0) to far to the left (-1) and back again, while every letter stays pinched at its top and bottom. The first frame, which is all a viewer that cannot animate shows, is the word leaning to the right.A real capture, 16 frames played in a loop - the word LEAN with TEXT_BULGE at depth 4, its lean swinging from far to the right (xshear 1) through standing straight up (0) to far to the left (-1) and back again, while every letter stays pinched at its top and bottom. The first frame, which is all a viewer that cannot animate shows, is the word leaning to the right.
A real capture, 16 frames played in a loop - the word LEAN with TEXT_BULGE at depth 4, its lean swinging from far to the right (xshear 1) through standing straight up (0) to far to the left (-1) and back again, while every letter stays pinched at its top and bottom. The first frame, which is all a viewer that cannot animate shows, is the word leaning to the right.

The xshear going 1, 0.92 ... 0 ... -1 and back (the number under the picture is the one in use). Sixteen real pictures, two frames apart, played at half the speed of the console. A viewer that does not animate shows the first frame.

Depth 0

depth 0 draws the flat line, and a flat line can lean too: it is draw_text_sheared with a scale of 1 and no turn. So you can switch the curve on and off with a variable and the lean stays. With a lean of 0 as well it is plain draw_text.

How far it can lean

A note on 12. Twelve is how many sprites one drawn thing can use in every game that has not changed Sprites in one drawn thing under Engine limits in Project Settings (it goes up to 32). Wherever this page says 12 letters, it means that number.

Every letter of a word of 12 letters or fewer (spaces do not count) is a sprite of its own, and the Game Boy Advance draws a slanted sprite only inside a box twice as wide and twice as tall as the sprite. Anything that slides outside the box is cut off, and nothing can make the box bigger. The letters of the normal fonts are square (8 by 8, 16 by 16 or 32 by 32 pixels), and for a square letter that box holds this much:

A real capture - a single letter W on the left, and the twelve letters ABCDEFGHIJKL on the right, each drawn three times with TEXT_BULGE, one under the other, leaning by 0, then 0.5, then 1. A single letter and a word of twelve letters lean in just the same wayA real capture - a single letter W on the left, and the twelve letters ABCDEFGHIJKL on the right, each drawn three times with TEXT_BULGE, one under the other, leaning by 0, then 0.5, then 1. A single letter and a word of twelve letters lean in just the same way
A real capture - a single letter W on the left, and the twelve letters ABCDEFGHIJKL on the right, each drawn three times with TEXT_BULGE, one under the other, leaning by 0, then 0.5, then 1. A single letter and a word of twelve letters lean in just the same way

One letter and twelve letters, each at a lean of 0, 0.5 and 1. The twelve letters are in the 8 pixel font, because twelve of the 32 pixel font are wider than the screen. Every letter of the word leans exactly as the single letter does.

One line only

The curve is made for a single line of text. A "\n" in the string ends the text there: only the first line is drawn, and what follows is left out. To curve several lines, draw each with its own call.

What it costs

It costs what draw_text_3d costs, and the lean adds nothing to the bill:

Ask for more than there is and the game stops, in a development build, with a message that names every call that is holding a slot (a 3D text, scaled or leaned, is named by its first letters). The line has already been drawn plain, upright and flat, when it stops, and a release build, which has no such stop, simply shows it that way. The effect never fails to appear: you are told.

Example

text_align(ALIGN_CENTER);
draw_text_3d_sheared(x, y - 24, "LEAN", TEXT_BULGE, 4, 0.5);

A label, centered above this instance, pinched at the top and bottom of every letter like a barrel seen close up, and leaning to the right like italic writing (depth 4 needs a bold 32 pixel font).

text_align(ALIGN_CENTER);
draw_text_3d_sheared(x, y - 24, "LEAN", TEXT_LEAN_BACK, 4, -0.5);

A sign tipped back, with the letters leaning to the left as well.

text_align(ALIGN_CENTER);
var lean = wave(-1, 1, 120, 0);
draw_text_3d_sheared(x, y - 24, "LEAN", TEXT_BULGE, 4, lean);

A word whose lean swings from -1 to 1 and back once every two seconds (120 frames), curved the whole time. A lean that changes is as cheap as one that stays.

On the GBA

Costs what draw_text_3d costs: ONE of the hardware’s 32 affine matrices and TWO of the console’s 8 row-by-row (H-Blank) effects, for as long as the call keeps being made. The lean is one more number in the same matrix and is the same on every row, so it needs no effect of its own, and changing it on every frame is nearly free (the letters are not built again). A room transition keeps two of the eight for itself, so at most three 3D things (texts, or sprites from draw_sprite_3d) can be on screen at once. A line with a lean is drawn in the bigger box (twice the sprite’s size in each direction, which the console takes about twice as long to draw), and a line with a lean of 0 goes back to the sprite’s own box. A letter that is as wide as it is tall (the normal fonts: 8 by 8, 16 by 16, 32 by 32) keeps every pixel up to an xshear of 1; a letter taller than it is wide (some title fonts are 16 wide and 32 tall) holds a lean of its width divided by its height, 0.5 for those, and past the limit the sides of the letters are cut off and nothing worse. Every letter gets a sprite of its own, so every letter leans by exactly what its own row asks and a word never leans in clumps. That holds for a word of up to 12 letters (spaces do not count). A longer word is still drawn, but its letters share sprites, up to four to a sprite, so it leans in clumps of letters; a development build says so once in the log, and drawing a long line as two calls keeps it even. Each letter counts toward the 128 sprites the screen can show at once, so a 12-letter word costs 12. depth 0 draws the flat line, leaned (draw_text_sheared with a scale of 1 and no turn: a matrix and no row-by-row effect), and with an xshear of 0 as well, plain draw_text. Asking for more than there is stops the game with a message that names every call holding a slot (the plain text has already been drawn when it stops, and a release build, which has no such stop, draws it upright and flat). Depths 4 to 6 need a font drawn from sprites 32 pixels tall (a smaller font is drawn at depth 3 and a development build says so once in the log). A line cannot also be turned: use draw_text_warped for that, without the curve, or draw_text_3d_scaled to make the line bigger, smaller or flipped.

See also: draw_text_3ddraw_text_sheareddraw_text_3d_scaleddraw_text_warpedtext_alignfont_set